#include "gamepanel.h"

GamePanel::GamePanel(QGraphicsItem * parent) : QGraphicsItem(parent)
{
    m_size = QPointF(0,0);
    setAcceptsHoverEvents(true);
    setZValue(100);
}

QRectF GamePanel::boundingRect() const
{
    return QRectF(0, 0, m_size.x(), m_size.y());
}

void GamePanel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    painter->save();
    QRectF sRect = boundingRect();
    // draw panel background
    QLinearGradient grad(QPointF(0, sRect.height() / 2.0), QPointF(sRect.width(), sRect.height() / 2.0));
    grad.setColorAt(0.0, QColor(70, 70, 70));
    grad.setColorAt(1.0, QColor(220, 220, 220));
    QBrush brush(grad);
    painter->setBrush(brush);
    painter->drawRect(0, 0, sRect.width(), sRect.height());
    painter->restore();
}
